export class Ret<T> {
  code: number

  data: T

  message: string | null

  constructor(code: number, data: T, message: string | null) {
    this.code = code
    this.data = data
    this.message = message
  }

  static async ok<T>(data?: T) {
    return new Ret(200, (await data) ?? null, null)
  }

  static async fail(message = '服务器内部错误', code = -1) {
    return new Ret(code, null, message)
  }
}
